#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QBuffer>
#include <QByteArray>
#include <QImageReader>
#include <QTcpServer>
#include <QTcpSocket>
#include <QHostAddress>
#include <QHostInfo>
#include <QNetworkInterface>
#include <QHostAddress>
#include <QList>
#include <QString>
#include <QMessageBox>
#include <QImage>
#include <QTimer>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QGraphicsItem>
#include <iostream>
/* Opencv库 */
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "collectpictureupper.h"

using namespace cv;
using namespace std;

#define DEBUG
#define ShowWindowSizeWidht    640
#define ShowWindowSizeHeight   480

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    QImage Mat2QImage(const cv::Mat& mat); //Mat转 QImage
    Mat QImage2Mat(QImage image); //QImage转Mat
    void openCamera();
    void closeCamera();

public slots:
    void on_pushButton_clicked();
    void getCameraFrame(Mat *frame);
    void readReadySlot();
    void sendPicture();
private:
    Ui::Widget *ui;
    QRect          rect;
    QGraphicsView  *view;
    QGraphicsScene *scene;
    QGraphicsPixmapItem  item;
    QTimer *time1;

    QImage send_image;
    bool button_flag;
    collectPictureUpper thread;
    QTcpSocket socket;
    QString    serverIP;//服务器ip
    uint       serverPort = 9999;//服务器port

    QByteArray dataArray;
};

#endif // WIDGET_H
